import {uniqueId} from '@/utils';
import {makeRequiredRule} from '../../utils';

const label = '输入框';
const name = 'input';

export default {
	icon: 'icon-input',
	label,
	name,
	rule() {
		return {
			type: name,
			field: uniqueId(),
			title: label,
			info: '',
			col:12,
			showLable:true,
			labelWidth:'',
			$required: false,
			props: {},
		};
	},
	props() {
		return [makeRequiredRule(), {
			type: 'select',
			field: 'type',
			title: '类型',
			value:'',
			options: [{
				label: 'text',
				value: 'text'
			}, {
				label: 'textarea',
				value: 'textarea'
			}, {
				label: 'number',
				value: 'number'
			}, {
				label: 'password',
				value: 'password'
			}]
		}, {
			type: 'input-number',
			field: 'maxlength',
			title: '最大输入长度',
			value:'',
			props: {
				min: 0
			}
		}, {
			type: 'input-number',
			field: 'minlength',
			title: '最小输入长度',
			value:'',
			props: {
				min: 0
			}
		}, {
			type: 'switch',
			field: 'showWordLimit',
			value:'',
			title: '是否显示输入字数统计'
		}, {
			type: 'input',
			field: 'placeholder',
			value:'',
			title: '输入框占位文本'
		}, {
			type: 'switch',
			field: 'clearable',
			value:false,
			title: '是否可清空'
		}, {
			type: 'switch',
			value:false,
			field: 'showPassword',
			title: '是否显示切换密码图标'
		}, {
			type: 'switch',
			field: 'disabled',
			value:false,
			title: '禁用'
		}, {
			type: 'input',
			field: 'prefixIcon',
			value:'',
			title: '前图标'
		}, {
			type: 'input',
			field: 'suffixIcon',
			value:'',
			title: '后图标'
		},
		{
			type: 'input',
			field: 'prepend',
			value:'',
			title: '输入框前缀'
		}, {
			type: 'input',
			field: 'append',
			value:'',
			title: '输入框后缀'
		},{
			type: 'input-number',
			field: 'rows',
			info: '只对 type="textarea" 有效',
			title: '输入框行数',
			value:'',
			props: {
				min: 0
			}
		}, {
			type: 'select',
			field: 'autocomplete',
			title: '自动补全',
			value:false,
			options: [{
				label: 'on',
				value: 'on'
			}, {
				label: 'off',
				value: 'off'
			}]
		}, {
			type: 'switch',
			field: 'readonly',
			value:false,
			title: '是否只读'
		}, {
			type: 'select',
			field: 'resize',
			title: '控制是否能被用户缩放',
			value:'',
			options: [{
				label: 'none',
				value: 'none'
			}, {
				label: 'both',
				value: 'both'
			}, {
				label: 'horizontal',
				value: 'horizontal'
			}, {
				label: 'vertical',
				value: 'vertical'
			}]
		},{
			type: 'select',
			field: 'size',
			title: '输入框尺寸',
			info: '只对 type!="textarea" 有效',
			value:'',
			options: [{
				label: 'medium ',
				value: 'medium '
			}, {
				label: 'small ',
				value: 'small '
			}, {
				label: 'mini',
				value: 'mini'
			}]
		}, {
			type: 'switch',
			field: 'autofocus',
			value:false,
			title: '自动获取焦点'
		}];
	}
};